<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
    <!-- 包含公共的JSP代码片段 -->

    <title>无线点餐平台</title>



    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="style/js/jquery.js"></script>
    <script type="text/javascript" src="style/js/page_common.js"></script>
    <link href="style/css/common_style_blue.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="style/css/index_1.css" />
</head>
<body>

<!-- 页面标题 -->
<div id="TitleArea">
    <div id="TitleArea_Head"></div>
    <div id="TitleArea_Title">
        <div id="TitleArea_Title_Content">



            <img border="0" width="13" height="13" src="style/images/title_arrow.gif"/> 添加新商品


        </div>
    </div>
    <div id="TitleArea_End"></div>
</div>

<!-- 主内容区域（数据列表或表单显示） -->
<div id="MainArea">
    <!-- 表单内容 -->
    <form action="../add_Dessert.action" method="post" enctype="multipart/form-data">
        <!-- 本段标题（分段标题） -->
        <div class="ItemBlock_Title">
            <img width="4" height="7" border="0" src="style/images/item_point.gif"> 商品信息&nbsp;
        </div>
        <!-- 本段表单字段 -->
        <div class="ItemBlockBorder">
            <div class="ItemBlock">
                <div class="ItemBlock2">
                    <table cellpadding="0" cellspacing="0" class="mainForm">
                        <tr>
                            <td width="80px">商品类型</td>
                            <td>
                                <select name="dessert.dessertType" style="width:80px">

                                    <c:forEach items="${list}" var="c">
                                        <option value="${c.typeId}">${c.typeName}</option>
                                    </c:forEach>

                                </select>
                                *<input type="hidden" name="" value="" /></td>
                        </tr>
                        <tr>
                            <td width="80px">商品名称</td>
                            <td><input type="text" id="foodName" name="dessert.dessertName" class="InputStyle" value=""/> *</td>
                        </tr>
                        <tr>
                            <td>商品价格</td>
                            <td><input type="text" id="price" name="dessert.dessertPrice" class="InputStyle" value=""/> *</td>
                        </tr>

                        <tr>
                            <td>商品简介</td>
                            <td><textarea id="introduce" name="dessert.desertMark" class="TextareaStyle"></textarea></td>
                        </tr>
                        <tr>
                            <td width="80px">商品图片</td>
                            <td>

                                <input type="file" id="imageUrl" name="file1"/> *
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>


        <!-- 表单操作 -->
        <div id="InputDetailBar">



            <input type="submit" value="添加" class="FunctionButtonInput">



            <a href="javascript:history.go(-1);" class="FunctionButton">返回</a>
        </div>
    </form>
</div>
</body>
<script type="text/javascript">
    $(function () {
        $("form").submit(function () {
            var name = $("input[id=foodName]").val();
            name  = $.trim(name);
            if(name==null || name==""){
                alert("商品名不能为空...");
                return false;
            }
            else {
                var price = $("input[id=price]").val();
                price  = $.trim(price);
                if(price==null || price==""){
                    alert("商品价格不能为空...");
                    return false;
                }
                else {
                   if (isNaN(price)){
                        alert("商品价格只能是数字...");
                        return false;
                   }
                   else {
                       var imageUrl = $("input[id=imageUrl]").val();
                       imageUrl  = $.trim(imageUrl);
                       if(imageUrl==null || imageUrl==""){
                           alert("请选择商品图片...");
                           return false;
                       }
                       else {
                           return true;
                       }
                   }
                }
            }
        })
    });
</script>
</html>
